From: Mary Boetcher, mary_boetcher@quickmail.apple.com
Reply-To: ODF Interest, ODF-Interest@CILabs.ORG
To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
Reply to: RE>>Text Reader
>>If I want to copy from a text reader to a string, would the following loop
>>be both OK and efficient?
I think the following code would be slightly more efficient, since there are fewer function calls. It relies on the fact that the text reader returns a null character when it reaches the end of its text:
FW_CString string;
while (true)
{
FW_LChar ch = reader->GetCharacterAndAdvance();
if (ch == 0) break; // end of text
string.Append(ch);
if (ch == chTab || ch == chReturn)
break;
}
>>Also, why do you allocate the reader with the FW_NEW operator instead of
>>allocating it on the stack?
I copied that code from my test part, which keeps the reader in a data member: